#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <sys/epoll.h>
#define TIMEOUT 5000

int main()
{
    int timeout = TIMEOUT;
    time_t start = time(NULL);
    time_t end = time(NULL);
    while (1)
    {
        printf("the timeout is now %d mil-seconds\n", timeout);
        start = time(NULL);
        int number = epoll_wait(epollfd, MAX_EVENT_NUMBER, timeout);
        if(number < 0 && errno != EINTR)
        {
            printf("epoll failure\n");
            break;
        }
        if(number == 0)
        {
            timeout = TIMEOUT;
            continue;
        }
        end = time(NULL);
        timeout -= (end - start) * 1000;
        if(timeout <= 0)
        {
            timeout = TIMEOUT;
        }
    }
    return 0;
}